package com.m3839.sdk.pay.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Description:支付结果
 *
 * @author 陈宝阳
 * @create 2020/8/6 14:46
 */
public class PayResult implements Parcelable {

  /**
   * 结果code
   */
  public int resultCode;

  /**
   * 支付的结果描述
   */
  public String message;


  public PayInfo payInfo;

  public String payChannel;

  public String orderId;

  public PayResult(){}

  protected PayResult(Parcel in) {
    resultCode = in.readInt();
    message = in.readString();
    payInfo = in.readParcelable(PayInfo.class.getClassLoader());
    payChannel = in.readString();
    orderId = in.readString();
  }

  public static final Creator<PayResult> CREATOR = new Creator<PayResult>() {
    @Override
    public PayResult createFromParcel(Parcel in) {
      return new PayResult(in);
    }

    @Override
    public PayResult[] newArray(int size) {
      return new PayResult[size];
    }
  };

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(resultCode);
    dest.writeString(message);
    dest.writeParcelable(payInfo, flags);
    dest.writeString(payChannel);
    dest.writeString(orderId);
  }

  public boolean isSuccess() {
    return resultCode == 9000;
  }


  @Override
  public String toString() {
    return "PayResult{" +
            "resultCode=" + resultCode +
            ", message='" + message + '\'' +
            ", payInfo=" + payInfo +
            ", payChannel='" + payChannel + '\'' +
            ", orderId='" + orderId + '\'' +
            '}';
  }
}
